package cn.idu.socket.udp.chat;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPReceive {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(6666);
        byte[] data = new byte[1024];
        while (true) {
            DatagramPacket packet = new DatagramPacket(data, data.length);
            socket.receive(packet);
            String receive_data = new String(packet.getData());
            System.out.println(receive_data);
            if (receive_data.equals("bye")) {
                break;
            }
        }
        socket.close();

    }
}
